import drawQrcode from "../../utils/qrcode/weapp.qrcode.esm"

Page({
  data: {
    result: ""
  },
  onLoad(query) {
    // console.log(drawQrcode)
    drawQrcode({
      width: 200,
      height: 200,
      canvasId: 'myQrcode',
      // ctx: wx.createCanvasContext('myQrcode'),
      text: 'hello qrcode',
      // v1.0.0+版本支持在二维码上绘制图片
      image: {
        imageResource: '/images/temp/wbb.jpeg',
        dx: 70,
        dy: 70,
        dWidth: 60,
        dHeight: 60
      }
    })
  },
  scanCode() {
    const self = this
    wx.scanCode({
      success (res) {
        console.log(res)
        self.setData({
          result: res.result
        })
      },
      fail(res) {
        console.log(res)
      }
    })
  },
  copy() {
    wx.setClipboardData({
      data: this.data.result,
      success (res) {
        console.log(res)
        wx.vibrateLong()
      }
    })
    // console.log(this.data.result)
  },
  call() {
    wx.makePhoneCall({
      phoneNumber: '13211002233'
    })
    wx.getBatteryInfo({
      success(res) {
        console.log(res)
      }
    })

    wx.getNetworkType({
      success (res) {
        console.log(res)
      }
    })
  }
})
